<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::group(['middleware'=>['web']],function(){
    Route::get('/', function () {
        return view('welcome');
    });

    Route::get('/index', 'IndexController@index');
    Route::any('/add', 'IndexController@add');
    Route::any('/edit/{id?}', 'IndexController@edit');
    Route::any('/update/{id?}', 'IndexController@update');
    Route::get('/lists', 'IndexController@lists');
    Route::get('/delete/{id?}', function($id=0){
        //\Illuminate\Support\Facades\DB::delete('delete from mall_ad where id = ?',[$id]);
        \Illuminate\Support\Facades\DB::table('mall_ad')->where('id',$id)->update(['is_delete'=>1]);
        return redirect('lists');
    });

    //查询构建器训练    get方法获取所有记录
    Route::get('/get', 'SelectController@get_data');
    //first方法获取一条记录
    Route::get('/first', 'SelectController@first_data');
    //chunk方法，获取结果集的一小块
    Route::get('/chunk', 'SelectController@chunk_data');
    //入口
    Route::get('/test', 'SelectController@index');
});